{"mode":"Blocks","workspace":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><variables><variable type=\"\" id=\"_2.^beQjx|FGt38A,8(E\" islocal=\"false\" iscloud=\"false\" arraylength=\"0\" arraywidth=\"0\">myVariable</variable></variables><block type=\"iq_events_when_started\" id=\".NsXwU_L.OuU1l7Sho$F\" x=\"-290\" y=\"-190\"><next><block type=\"iq_motion_set_motor_stopping\" id=\"FJ)3*=fwN@O(6cp83s*T\"><field name=\"MOTOR\">IntakeGroup</field><field name=\"MODE\">hold</field><next><block type=\"iq_motion_set_motor_stopping\" id=\"RxIQ,_B*#TnIr?jp0IQB\"><field name=\"MOTOR\">ArmGroup</field><field name=\"MODE\">hold</field></block></next></block></next></block></xml>","rconfig":[{"port":[5,11],"name":"IntakeGroup","customName":true,"deviceType":"MotorGroup","deviceClass":"motor_group","setting":{"fwd":"forward","rev":"reverse","motor_a_reversed":"false","motor_b_reversed":"true"},"triportSourcePort":22},{"port":[6,12],"name":"ArmGroup","customName":true,"deviceType":"MotorGroup","deviceClass":"motor_group","setting":{"fwd":"forward","rev":"reverse","motor_a_reversed":"true","motor_b_reversed":"false"},"triportSourcePort":22},{"port":[10],"name":"TopTouchLED","customName":true,"deviceType":"TouchLED","deviceClass":"touchled","setting":{},"triportSourcePort":22},{"port":[3],"name":"IntakeBumper","customName":true,"deviceType":"Bumper","deviceClass":"bumper","setting":{},"triportSourcePort":22},{"port":[4],"name":"IntakeOptical","customName":true,"deviceType":"Optical","deviceClass":"optical","setting":{},"triportSourcePort":22},{"port":[9],"name":"FrontDistance","customName":true,"deviceType":"Distance","deviceClass":"distance","setting":{},"triportSourcePort":22},{"port":[],"name":"Controller","customName":false,"deviceType":"Controller","deviceClass":"controller","setting":{"left":"IntakeGroup","leftDir":"false","right":"ArmGroup","rightDir":"false","e":"","eDir":"false","f":"","fDir":"false","l3r3":"","l3r3Dir":"false","drive":"tank"},"triportSourcePort":22},{"port":[1,7,0],"name":"Drivetrain","customName":false,"deviceType":"Drivetrain","deviceClass":"smartdrive","setting":{"type":"2-motor","wheelSize":"200mm","gearRatio":"1:1","direction":"fwd","gyroType":"integrated","width":"173","unit":"mm","wheelbase":"76","wheelbaseUnit":"mm","xOffset":"0","yOffset":"0","thetaOffset":"0"}}],"slot":0,"platform":"IQ","sdkVersion":"20220726.10.00.00","appVersion":"2.4.5","minVersion":"2.4.0","fileFormat":"1.2.0","icon":"","targetBrainGen":"Second","cppStatus":"true","cpp":"// Make sure all required headers are included.\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <math.h>\n#include <string.h>\n\n\n#include \"vex.h\"\n\nusing namespace vex;\n\n// Brain should be defined by default\nbrain Brain;\n\n\n// START IQ MACROS\n#define waitUntil(condition)                                                   \\\n  do {                                                                         \\\n    wait(5, msec);                                                             \\\n  } while (!(condition))\n\n#define repeat(iterations)                                                     \\\n  for (int iterator = 0; iterator < iterations; iterator++)\n// END IQ MACROS\n\n\n// Robot configuration code.\ninertial BrainInertial = inertial();\nmotor IntakeGroupMotorA = motor(PORT5, false);\nmotor IntakeGroupMotorB = motor(PORT11, true);\nmotor_group IntakeGroup = motor_group(IntakeGroupMotorA, IntakeGroupMotorB);\n\nmotor ArmGroupMotorA = motor(PORT6, true);\nmotor ArmGroupMotorB = motor(PORT12, false);\nmotor_group ArmGroup = motor_group(ArmGroupMotorA, ArmGroupMotorB);\n\ntouchled TopTouchLED = touchled(PORT10);\nbumper IntakeBumper = bumper(PORT3);\noptical IntakeOptical = optical(PORT4);\ndistance FrontDistance = distance(PORT9);\ncontroller Controller = controller();\nmotor LeftDriveSmart = motor(PORT1, 1, false);\nmotor RightDriveSmart = motor(PORT7, 1, true);\n\nsmartdrive Drivetrain = smartdrive(LeftDriveSmart, RightDriveSmart, BrainInertial, 200);\n\n\nvoid calibrateDrivetrain() {\n  wait(200, msec);\n  Brain.Screen.print(\"Calibrating\");\n  Brain.Screen.newLine();\n  Brain.Screen.print(\"Inertial\");\n  BrainInertial.calibrate();\n  while (BrainInertial.isCalibrating()) {\n    wait(25, msec);\n  }\n\n  // Clears the screen and returns the cursor to row 1, column 1.\n  Brain.Screen.clearScreen();\n  Brain.Screen.setCursor(1, 1);\n}\n\n// Generated code.\n\n\n\n// define variable for remote controller enable/disable\nbool RemoteControlCodeEnabled = true;\n// define variables used for controlling motors based on controller inputs\nbool ControllerLeftShoulderControlMotorsStopped = true;\nbool ControllerRightShoulderControlMotorsStopped = true;\nbool DrivetrainLNeedsToBeStopped_Controller = true;\nbool DrivetrainRNeedsToBeStopped_Controller = true;\n\n// define a task that will handle monitoring inputs from Controller\nint rc_auto_loop_function_Controller() {\n  // process the controller input every 20 milliseconds\n  // update the motors based on the input values\n  while(true) {\n    if(RemoteControlCodeEnabled) {\n      \n      // calculate the drivetrain motor velocities from the controller joystick axies\n      // left = AxisA\n      // right = AxisD\n      int drivetrainLeftSideSpeed = Controller.AxisA.position();\n      int drivetrainRightSideSpeed = Controller.AxisD.position();\n      \n      // check if the value is inside of the deadband range\n      if (drivetrainLeftSideSpeed < 5 && drivetrainLeftSideSpeed > -5) {\n        // check if the left motor has already been stopped\n        if (DrivetrainLNeedsToBeStopped_Controller) {\n          // stop the left drive motor\n          LeftDriveSmart.stop();\n          // tell the code that the left motor has been stopped\n          DrivetrainLNeedsToBeStopped_Controller = false;\n        }\n      } else {\n        // reset the toggle so that the deadband code knows to stop the left motor nexttime the input is in the deadband range\n        DrivetrainLNeedsToBeStopped_Controller = true;\n      }\n      // check if the value is inside of the deadband range\n      if (drivetrainRightSideSpeed < 5 && drivetrainRightSideSpeed > -5) {\n        // check if the right motor has already been stopped\n        if (DrivetrainRNeedsToBeStopped_Controller) {\n          // stop the right drive motor\n          RightDriveSmart.stop();\n          // tell the code that the right motor has been stopped\n          DrivetrainRNeedsToBeStopped_Controller = false;\n        }\n      } else {\n        // reset the toggle so that the deadband code knows to stop the right motor next time the input is in the deadband range\n        DrivetrainRNeedsToBeStopped_Controller = true;\n      }\n      \n      // only tell the left drive motor to spin if the values are not in the deadband range\n      if (DrivetrainLNeedsToBeStopped_Controller) {\n        LeftDriveSmart.setVelocity(drivetrainLeftSideSpeed, percent);\n        LeftDriveSmart.spin(forward);\n      }\n      // only tell the right drive motor to spin if the values are not in the deadband range\n      if (DrivetrainRNeedsToBeStopped_Controller) {\n        RightDriveSmart.setVelocity(drivetrainRightSideSpeed, percent);\n        RightDriveSmart.spin(forward);\n      }\n      // check the ButtonLUp/ButtonLDown status to control IntakeGroup\n      if (Controller.ButtonLUp.pressing()) {\n        IntakeGroup.spin(forward);\n        ControllerLeftShoulderControlMotorsStopped = false;\n      } else if (Controller.ButtonLDown.pressing()) {\n        IntakeGroup.spin(reverse);\n        ControllerLeftShoulderControlMotorsStopped = false;\n      } else if (!ControllerLeftShoulderControlMotorsStopped) {\n        IntakeGroup.stop();\n        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released\n        ControllerLeftShoulderControlMotorsStopped = true;\n      }\n      // check the ButtonRUp/ButtonRDown status to control ArmGroup\n      if (Controller.ButtonRUp.pressing()) {\n        ArmGroup.spin(forward);\n        ControllerRightShoulderControlMotorsStopped = false;\n      } else if (Controller.ButtonRDown.pressing()) {\n        ArmGroup.spin(reverse);\n        ControllerRightShoulderControlMotorsStopped = false;\n      } else if (!ControllerRightShoulderControlMotorsStopped) {\n        ArmGroup.stop();\n        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released\n        ControllerRightShoulderControlMotorsStopped = true;\n      }\n    }\n    // wait before repeating the process\n    wait(20, msec);\n  }\n  return 0;\n}\n\ntask rc_auto_loop_task_Controller(rc_auto_loop_function_Controller);\n\n// Include the IQ Library\n#include \"vex.h\"\n  \n// Allows for easier use of the VEX Library\nusing namespace vex;\n\nfloat myVariable;\n\n// \"when started\" hat block\nint whenStarted1() {\n  IntakeGroup.setStopping(hold);\n  ArmGroup.setStopping(hold);\n  return 0;\n}\n\n\nint main() {\n  // Calibrate the Drivetrain Gyro\n  calibrateDrivetrain();\n\n  whenStarted1();\n}","target":"Physical"}